package com.wectrls.security;

import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author chenjian
 * @Package
 * @Description:
 * @date 2019/7/5 10:25
 */
public class SecurityCommonUtils {

    /**
     * 未登录得默认用户名
     */
    public static final String defLoginUserNme = "anonymousUser";

    /**
     * 获取当前登陆用户
     *
     * @return
     */
    public static synchronized String CurrentLoginUser() {
        //anonymousUser
        String loginUserName = SecurityContextHolder.getContext().getAuthentication().getName();
        return loginUserName;
    }
}
